﻿using System;
using System.Linq;

public partial class Blog : System.Web.UI.Page
{
    chodientuDataContext db = new chodientuDataContext();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["User"] == null)
        {
            Response.Redirect("chuadangnhap.aspx");
        }   
        string mabaiviet = Request.QueryString["id"].ToString();
        string user = Session["user"].ToString();

        var query = from bv in db.Baiviets
                    from bl in db.Nhatkies
                    where bl.Username.Equals(user) && bv.Mablog.Equals(bl.Mablog) && bv.Mabaiviet.Equals(mabaiviet)
                    select bv;

        if (query.Count() != 0)
        {
            //contentID.Visible = true;
            foreach (var i in query)
            {
                tieudeID.InnerText = i.Tieude;
                noidungID.InnerHtml = i.Noidung;
                ngaydangID.InnerText = i.Ngaydang.ToString();
                quyenID.InnerText = i.Quyenriengtu;
            }
        }
        else {
            noContentID.Visible = true;
        }
    }

}